package sevensoft.gz031.demos.web.response;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R <T>{

    public Integer code;
    public String msg;
    public T data;

    public static final Integer OK=200;

    public static final Integer NO=201;

    public static final Integer ACCESS_WRONG=202;


    public static <T> R<T> ok(){
        return new R<>(OK,null,null);
    }

    public static <T> R<T> ok(T data){
        return new R<>(OK,null,data);
    }

    public static <T> R<T> ok(T data,String msg){
        return new R<>(OK,msg,data);
    }

    public static <T> R<T> no(){
        return new R<>(NO,null,null);
    }

    public static <T> R<T> no(String msg){
        return new R<>(NO,msg,null);
    }

    public static <T> R<T> accessNo(String msg){
        return new R<>(ACCESS_WRONG,msg,null);
    }
}
